package com.tianyuan.lims.dms.common;

import com.jfinal.aop.Interceptor;
import com.jfinal.aop.Invocation;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class DmsInterceptor implements Interceptor {
    @Override
    public void intercept(Invocation invocation) {
        HttpServletRequest request = invocation.getController().getRequest();
        HttpServletResponse response = invocation.getController().getResponse();

        // 允许跨域的域名，*代表允许任何域名
        response.setHeader("Access-Control-Allow-Origin", "*");
        // 允许的方法
        response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE");
        // 允许的头信息字段
        response.setHeader("Access-Control-Allow-Headers", "x-requested-with, content-type");
        invocation.invoke();
    }
}
